//
//  CustomSearchBar.h
//  Etion
//
//  Created by JingXing Wu on 11-11-29.
//  Copyright (c) 2011年 GuangZhouXuanWu. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "DropDownButton.h"

typedef NS_ENUM(NSUInteger,XUISearchBarStyleType)
{
    XUISearchBarStyleTypeDefault = 1 << 0,
    XUISearchBarStyleTypeFilter = 1 << 1,
    XUISearchBarStyleTypeCodeBar = 1 << 2,
    XUISearchBarStyleTypeHideable = 1 << 3
//    XUISearchBarStyleTypeCodeBarONLY    = 1 << 3
};

@class XUISearchBar;

@protocol XUISearchBarDelegate <NSObject>

@optional

- (void)barCodeClicked:(XUISearchBar *)searchbar;

- (BOOL)clearSearchField:(XUISearchBar *)searchbar;

- (void)dropDownButtonClick:(XUISearchBar *)searchbar dropDownBtn:(CDropDownButton *)button;

- (BOOL)searchBarShouldBeginEditing:(XUISearchBar *)searchbar;

- (void)searchBarTextDidBeginEditing:(XUISearchBar *)searchbar;

- (BOOL)searchBarShouldEndEditing:(XUISearchBar *)searchbar;

- (void)searchBarTextDidEndEditing:(XUISearchBar *)searchbar;

- (void)searchBar:(XUISearchBar *)searchbar textDidChange:(NSString *)searchText;

- (BOOL)searchBar:(XUISearchBar *)searchbar shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;

- (BOOL)searchBarSearchButtonClicked:(XUISearchBar *)searchbar;

- (void)searchBarHideButtonClicked:(XUISearchBar *)searchbar;

- (void)searchBarResetFilter:(XUISearchBar *)searchbar dropDownBtn:(CDropDownButton *)button;

@end

@interface XUISearchBar : UIView <UISearchBarDelegate, CDropDownButtonDelegate>
{
}

@property(nonatomic, readonly) CDropDownButton *ddbtn;
@property(nonatomic, assign) XUISearchBarStyleType type;
@property(nonatomic, retain) UIImage *backgroundimage;  //default is tableviewheaderbg.png
@property(nonatomic, assign) id <XUISearchBarDelegate> delegate;
@property(nonatomic, retain) NSString *searchText;
@property(nonatomic, assign) CGFloat customAreaW;
@property(nonatomic, readonly) UITextField *searchfield;
@property(nonatomic, retain) NSString *hiddenLabelText;

- (id)initWithFrame:(CGRect)frame styleType:(XUISearchBarStyleType)type;
- (id)initWithFrame:(CGRect)frame styleType:(XUISearchBarStyleType)type customAreaWidth:(CGFloat)customAreaWidth;

@end

